package com.activity.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.activity.bean.EmployerBean;
import com.activity.bean.UserBean;
import com.example.apple.ddhr_new.R;
import com.example.apple.ddhr_new.adapter.BaseAdapter;

import butterknife.BindView;

public class AttanceMember1Adapter extends BaseAdapter<UserBean> {


    public MonthAdapter.MonthListener monthListener;
    public String beginTime;
    public String endTime;
    public AttanceMember1Adapter(Context context) {
        super(context);
    }




    @Override
    public boolean hasHeader(int groupPosition) {
        return true;
    }

    @Override
    public int getHeaderLayout(int viewType) {
        return R.layout.header_define_query;
    }

    @Override
    public BaseViewHolder<UserBean> getViewHolder(int viewType, View view) {

        if(viewType==TYPE_CHILD)
        return new MemberHolder(view);

        return null;
    }

    @Override
    public int getChildLayout(int viewType) {
        return R.layout.item_attance_member1_cell;
    }



    @Override
    public void onBindHeaderViewHolder(com.donkingliang.groupedadapter.holder.BaseViewHolder holder, int groupPosition) {
        holder.itemView.findViewById(R.id.tv_begin_time).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (monthListener != null) {
                    monthListener.beginTimeClick();
                }
            }
        });
        holder.itemView.findViewById(R.id.tv_end_time).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (monthListener != null) {
                    monthListener.endTimeClick();
                }
            }
        });
        holder.itemView.findViewById(R.id.tv_query).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (monthListener != null) {
                    monthListener.queryClick();
                }
            }
        });


        TextView begin =holder.itemView.findViewById(R.id.tv_begin_time);
        TextView end =holder.itemView.findViewById(R.id.tv_end_time);

        if(beginTime!=null){
            begin.setText(beginTime);
            begin.setTextColor(mContext.getResources().getColor(R.color.black));
        }

        if(endTime!=null){
            end.setText(endTime);
            end.setTextColor(mContext.getResources().getColor(R.color.black));
        }

    }

    public class MemberHolder extends BaseViewHolder<UserBean> {

        @BindView(R.id.tv_name)
        TextView tvName;

        public MemberHolder(@NonNull View itemView) {
            super(itemView);

        }

        public void setData(UserBean data) {


            tvName.setText(data.getUsernickname());

        }


    }


}
